<?php

/** 职业类型 */
namespace app\voip\func;


use app\voip\model\EJobType;

class JobTypeFunc
{
    /**
     * @param $data
     * @return array|false
     * @throws \Exception
     */
    static function addAll($data)
    {
        $obj=new EJobType();
        return $obj->saveAll($data);
    }

    /**
     * @param $data
     * @return mixed
     * @throws \think\exception\DbException
     */
    static function checkSave($data)
    {

        $resultData=[];
        foreach ($data as $key=>$val)
        {
            $res=EJobType::get(['type_name'=>$val]);
            if ($res){
                $resultData[$val]=$res->id;
            }else{
                $res=EJobType::create(['type_name'=>$val]);
                $resultData[$val]=$res->id;
            }
        }
        return $resultData;
    }

    /**
     * @param $where
     * @return mixed
     * @throws \think\exception\DbException
     */
    static public function find($where)
    {
        return EJobType::get($where);
    }
}